import {
	chargeDepositMakeOrder,
  zfbDepositPay
} from '@/api/user.js'
export default {
	data() {
		return {
			deviceNo: ''
		}
	},
	methods: {
		// 确认购买押金
		async confDeposit(type, handle, isConf) {
			if (isConf) {
				const content = '您确定要购买 ' + this.btType + 'V 的电池押金？'
				const result = await this.confirm({
					content
				})
				if (!result.confirm) {
					return false
				}
			}
			const res = await zfbDepositPay({
				agentId: this.deviceNo,
				btType: this.btType || '',
			})
			this.wx_payment(res.data, result => {
				if (result == 1) {
					handle && handle()
				} else {
					this.toast('取消支付')
				}
			})
		},
		// 确认购买押金2
		async confDeposit2(agentId, btTypeId, deviceId, deviceNo) {
			const res = await zfbDepositPay({
				agentId: agentId,
				btTypeId: btTypeId || '',
			})
			this.wx_payment(res.data, result => {
        console.log(result,'resultresultresultresult')
				if (result == 1) {
					this.toast('支付成功，即将跳转电池套餐页面...')
					setTimeout(() => {
            uni.redirectTo({
            	url: `/pages/user/rentEle/package?type=2&deviceId=${deviceId}&deviceNo=${deviceNo}`
            });
						// this.routerLink({
						// 	path: '/pages/user/rentEle/package',
						// 	query: {
						// 		type: 2,
						// 		deviceId: deviceId,
						// 		deviceNo: deviceNo,
						// 	}
						// })
					}, 2000)
				} else {
					this.toast('取消支付')
				}
			})
		},
	}
}
